#include <iostream>
#include <utility>
#include <functional>

class Foo {
public:
    void print_sum(int n1, int n2)
    {
		data = n1+n2;
        std::cout << n1+n2 << '\n';
    }
public:
	int data = 10;
};

int main()
{
    int n = 1;
    int a[5] = {1, 2, 3, 4, 5};
 
    // 从二个 int 建造 pair
    auto p1 = std::make_pair(n, a[1]);
    std::cout << "The value of p1 is "
              << "(" << p1.first << ", " << p1.second << ")\n";
 
    // 从到 int 的引用和数组（退化成指针）建造 pair
    auto p2 = std::make_pair(std::ref(n), a);
    n = 7;
    std::cout << "The value of p2 is "
              << "(" << p2.first << ", "  << *(p2.second) << ", " << *(p2.second + 2) << ")\n";
	
	Foo foo;
    // 从到 int 的引用和数组（退化成指针）建造 pair
    auto p3 = std::make_pair(std::ref(n), std::ref(foo.data));
    n = 3;
    auto f3 = std::bind(&Foo::print_sum, &foo, 95, std::placeholders::_1);
    f3(5);
    std::cout << "The value of p2 is "
              << "(" << p3.first << ", "  << p3.second << ")\n";
	
}
